/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.helpdesk.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author JK
 */
@Entity
@Table(name = "PostCategores")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PostCategores.findAll", query = "SELECT p FROM PostCategores p"),
    @NamedQuery(name = "PostCategores.findById", query = "SELECT p FROM PostCategores p WHERE p.id = :id"),
    @NamedQuery(name = "PostCategores.findByName", query = "SELECT p FROM PostCategores p WHERE p.name = :name"),
    @NamedQuery(name = "PostCategores.findByIcon", query = "SELECT p FROM PostCategores p WHERE p.icon = :icon"),
    @NamedQuery(name = "PostCategores.findByStatus", query = "SELECT p FROM PostCategores p WHERE p.status = :status")})
public class PostCategores implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "Name")
    private String name;
    @Size(max = 250)
    @Column(name = "Icon")
    private String icon;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Status")
    private int status;
    @OneToMany(mappedBy = "categoryPostID")
    private List<Posts> postsList;

    public PostCategores() {
    }

    public PostCategores(Integer id) {
        this.id = id;
    }

    public PostCategores(Integer id, String name, int status) {
        this.id = id;
        this.name = name;
        this.status = status;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    @XmlTransient
    public List<Posts> getPostsList() {
        return postsList;
    }

    public void setPostsList(List<Posts> postsList) {
        this.postsList = postsList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PostCategores)) {
            return false;
        }
        PostCategores other = (PostCategores) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return name;
    }
    
}
